package com.haocang.szgm.ui.waterpoint.adapter;

import android.content.Context;

import com.haocang.szgm.R;
import com.haocang.szgm.ui.waterpoint.bean.WaterPointBean;
import com.haocang.commonlib.recyclerView.BaseAdapter;
import com.haocang.commonlib.recyclerView.BaseViewHolder;
import com.haocang.szgm.utils.tools.MyTextUtils;

/**
 * 创建时间：2019/3/5
 * 编 写 人：ShenC
 * 功能描述：
 */

public class WaterPointListAdapter extends BaseAdapter<WaterPointBean> {

    public WaterPointListAdapter(Context context) {
        super(context, R.layout.item_waterpoint_list);
    }

    @Override
    public void convert(BaseViewHolder holder, WaterPointBean bean) {




        if(bean.getIsDelete().equals("Y")){
            holder.setText(R.id.tv_status, "未积水")
                    .setBackgroundResource(R.id.tv_status, R.drawable.bt_green_01);
        }else if(bean.getIsDelete().equals("N")){
            holder.setText(R.id.tv_status, "未巡查")
                    .setBackgroundResource(R.id.tv_status, R.drawable.bt_gray_02);
        }else if(bean.getIsDelete().equals("S")) {
            if (bean.getStatus().equals("0")) {
                holder.setText(R.id.tv_status, "未处置")
                        .setBackgroundResource(R.id.tv_status, R.drawable.bt_red_01);
            } else if (bean.getStatus().equals("1")) {
                holder.setText(R.id.tv_status, "处置中")
                        .setBackgroundResource(R.id.tv_status, R.drawable.bt_orange_01);
            } else if (bean.getStatus().equals("2")) {
                holder.setText(R.id.tv_status, "已处理")
                        .setBackgroundResource(R.id.tv_status, R.drawable.bt_green_01);
            }
        }


        holder.setText(R.id.item_1, bean.getLocation());
        if(bean.getSeeperDepth() == null){
            holder.setText(R.id.item_1, bean.getLocation());
        }else{
            holder.setText(R.id.item_1, bean.getLocation());
        }

        holder.setText(R.id.item_2, bean.getArrangementName())
                .setText(R.id.item_3,bean.getStartWaterDate() == null?"":MyTextUtils.toYMDHM(bean.getStartWaterDate()))
                .setText(R.id.item_4,bean.getSeeperDepth() == null?"":bean.getSeeperDepth()+"cm")
                .setText(R.id.item_5,bean.getSeeperArea() == null?"":bean.getSeeperArea()+"m³");

        holder.addOnClickListener(R.id.item_lin);
    }

}